package com.qxy.hgz.util;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.Preference;
import android.preference.PreferenceManager;

/**
 * 将token 和 authCode 通过 SharedPreferences进行保存
 */

public class StorageUtil {
    private static SharedPreferences sharedPreferences;
    private static SharedPreferences.Editor editor;
    private static final String ACCESS = "access_token";
    private static final String CLIENT = "client_token";

    /**
     * 保存token的SharedPreferces
     * 注意：在DouYinApplication进行的初始化
     * @param _sharedPreferences application初始化的SharedPreferences
     */
    public static void init( SharedPreferences _sharedPreferences) {
        sharedPreferences = _sharedPreferences;

    }


    public static String getAccessToken() {
        return sharedPreferences.getString(ACCESS,"");
    }

    public static void addAccessToken(String token) {
        sharedPreferences.edit().putString(ACCESS,token).apply();
    }

    public static String getClientToken() {
        return sharedPreferences.getString(CLIENT,"");
    }

    public static void addClientToken(String token) {
        sharedPreferences.edit().putString(CLIENT,token).apply();
    }






}
